package com.itheima.health.controller;
import com.itheima.health.common.R;
import com.itheima.health.common.PageParam;
import com.itheima.health.common.ResultPageData;
import com.itheima.health.model.pojos.CheckItem;
import com.itheima.health.service.CheckItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class CheckItemController {
    @Autowired
    private CheckItemService checkItemService;

    @PostMapping("/checkitem/findPage")
    public ResultPageData findPage(@RequestBody PageParam pageParam) {
        System.out.println(pageParam);
        ResultPageData resultPageData = checkItemService.findPage(pageParam);
        return resultPageData;
    }

    @PostMapping("/checkitem/add")
    public R checkitemAdd(@RequestBody CheckItem checkItem) {
        checkItemService.checkitemAdd(checkItem);
        return R.success(null);
    }
    @GetMapping("/checkitem/findById")
    public R checkitemById(@RequestParam Integer id){
        CheckItem checkItem = checkItemService.checkitemById(id);
       return R.success(checkItem);
    }
    @PostMapping("/checkitem/edit")
    public R checkitemUpdate(@RequestBody CheckItem checkItem){
           checkItemService.checkItemUpdate(checkItem);
          return R.success(null);
    }
    @DeleteMapping("/checkitem/delete")
    public R checkitemDel(Integer id){
        checkItemService.del(id);
        return R.success(null);
    }
}
